zeek58.html


<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Set Time-Out and interval</title>
    <style>.container li{margin10px;}
    .container  strong{colorrgb(25555);displayblock;}
    #btn1{background-colordarkslategray;colorfloralwhite;cursorpointer;
margin-bottom20px;border-radius6px;}
    #btn1:hover{background-colorforestgreen;colorwhite;}
    #Time{colorred;background-colorwheat;font-size20px;}
    </style>
    
</head>
<body>
    <div class="container">
        <h1>Set Time-Out and interval using Timing Events.</h1>
        <p>The window object allows execution of code at specified time intervals.

            These time intervals are called timing events.</p>
            <ul>The two key methods to use with JavaScript are:
                <li> <strong>setTimeout(function, milliseconds)</strong>Executes a 
function, after waiting a specified number of milliseconds.</li>
            <li><strong>setInterval(function, milliseconds)</strong>Same as 
setTimeout(), but repeats the execution of the function continuously</li>
            Another thing in setInterval is:
            <li> <strong>let myVar = setInterval(function, milliseconds);</strong>
<strong>
                clearInterval(myVar);</strong>The clearInterval() method stops the
 executions of the function specified in the setInterval() method.</li>
        </ul>
        <p>Lets see how this button gives alert using timeout .2 seconds after 
clicking the button.</p>
        <button id="btn1"onclick="setTimeout(formSub2000,'Zeek','Bye')">
Form Submit
</button>


  <p>We can see time by using setInterval which repeats function repeated after 
cetain interval.The time is <span id="Time"></span> </p>


    </div>
    
</body>
<script>
    function formSub(name,greeting){
        alert("Form has been submitted by"+" "+name+" "+greeting)
    }

    // setTimeout(formSub(), 2000,'Zeek','Bye') ...using brackets after formSub 
is wrong.No brackets inside setTimeOut.
  function displayTime(){
      let timenew Date;
      console.log(Date);
      document.getElementById("Time").innerHTMLtime;}

      setInterval(displayTime,1000);

</script>
</html> 

Comments

Popular posts from this blog

INDEX OF ZEEK HTML,CSS and JS